package com.zzl.finance.order.constant;

import com.zzl.finance.order.dto.KeyValue;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : spp
 * @date : 2022/1/6 20:51
 */
public enum OrderStatusEnum {
    /**
     * 融资服务
     */
    PAID(1, "已支付", "已代缴"),
    UNPAID(2, "未支付", "未支付");

    private Integer code;
    private String value;
    private String coreValue;

    OrderStatusEnum(Integer code, String value, String coreValue) {
        this.code = code;
        this.value = value;
        this.coreValue = coreValue;
    }

    public static List<KeyValue> getList() {
        List<KeyValue> list = new ArrayList<>();
        for (OrderStatusEnum statusEnum : OrderStatusEnum.values()) {
            KeyValue keyValue = new KeyValue();
            keyValue.setKey(statusEnum.code);
            keyValue.setValue(statusEnum.value);
            list.add(keyValue);
        }
        return list;
    }

    public static List<KeyValue> getCoreList() {
        List<KeyValue> list = new ArrayList<>();
        for (OrderStatusEnum statusEnum : OrderStatusEnum.values()) {
            KeyValue keyValue = new KeyValue();
            keyValue.setKey(statusEnum.code);
            keyValue.setValue(statusEnum.coreValue);
            list.add(keyValue);
        }
        return list;
    }

    public static String getValue(Integer code) {
        for (OrderStatusEnum statusEnum : OrderStatusEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum.value;
            }
        }
        return "";
    }


    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getCoreValue() {
        return coreValue;
    }

}
